package com.qf.hospital.service.impl;

import com.qf.hospital.VO.DepartmentVO;
import com.qf.hospital.entity.Department;
import com.qf.hospital.mapper.DepartmentMapper;
import com.qf.hospital.service.DepartmentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/10/20 14:51
 */

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper mapper;

    /**
     * 查询所有科室类型
     * @return
     */
    @Override
    public List<DepartmentVO> findAll() {
        List<Department> departmentList = mapper.selectByExample(null);
        //封装
        List<DepartmentVO> data = new ArrayList<>();
        for (Department department : departmentList) {
            DepartmentVO departmentVO = new DepartmentVO();
            BeanUtils.copyProperties(department, departmentVO);
            data.add(departmentVO);
        }
        return data;
    }
}
